package com.wang.controller;

import com.wang.param.PostCollectionQueryParam;
import com.wang.reponse.PostVo;
import com.wang.result.BaseResponse;
import com.wang.result.ResultUtils;
import com.wang.user.model.PostCollection;
import com.wang.user.service.PostCollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/postcollection")
@Api(tags = "帖子收藏管理")
public class PostCollectionController {
    @Resource
    private PostCollectionService postCollectionService;

    @GetMapping("/list")
    @ApiOperation(value = "查看当前用户的收藏的帖子列表")
    public BaseResponse<List<PostVo>> listPostCollection(PostCollectionQueryParam queryParam) {
        return ResultUtils.success(postCollectionService.listPostCollection(queryParam));
    }

    @PostMapping("/submit")
    @ApiOperation(value = "收藏帖子")
    public BaseResponse<Boolean> submit(@RequestBody PostCollection postCollection) {
        return ResultUtils.success(postCollectionService.collection(postCollection));
    }

    @PostMapping("/cancel")
    @ApiOperation(value = "取消收藏")
    public BaseResponse<Boolean> cancel(@RequestBody PostCollection postCollection) {
        return ResultUtils.success(postCollectionService.cancel(postCollection));
    }
}
